package org.example.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.entity.Pinjia;

import java.util.List;

@Mapper
public interface Pinjiamapper {
    /**
     * 新增
     * @param pinjia
     */
    @Insert("INSERT INTO pinjia (image,name,shanpin,time,username,dingdanid,pj)\n" +
            "VALUES\n" +
            "(#{image},#{name},#{shanpin},#{time},#{username},#{dingdanid},#{pj})")
    void xz(Pinjia pinjia);

    /**
     * 查询
     * @param id
     * @return
     */
    @Select("select pj from pinjia where dingdanid=#{id}")
    String cx(int id);

    /**
     * 删除
     * @param id
     */
    @Delete("delete from pinjia where dingdanid=#{id}")
    void pj(int id);

    /**
     * 查询所有
     * @param id
     * @return
     */
    @Select("select * from pinjia where username=#{id}")
    List<Pinjia> cxsy(int id);
}
